<template>
  <div>
    <div class="top" v-show="showheader" @click="gocity">
      电影
      <span>
        {{ $store.state.city }}
        <i class="iconfont icon-xiajiantou"></i>
      </span>
    </div>
    <Header></Header>
    <router-view></router-view>
  </div>
</template>
<script>
import Header from '@/components/Header.vue'
export default {
  data() {
    return {
      showheader: false
    }
  },
  components: {
    Header
  },
  methods: {
    gocity() {
      this.$router.push('/city')
    }
  },
  mounted() {
    window.addEventListener('scroll', () => {
      const t = document.documentElement.scrollTop || document.body.scrollTop
      if (t >= 220) {
        this.showheader = true
      } else {
        this.showheader = false
      }
    })
  }
}
</script>
<style lang="scss" scoped>
.top {
  width: 100%;
  height: 44px;
  background-color: #fff;
  text-align: center;
  line-height: 44px;
  font-size: 17px;
  position: fixed;
  left: 0;
  top: 0;
  z-index: 2;
  span {
    font-size: 12px;
    position: absolute;
    left: 20px;
    top: 0;
  }
}
</style>